Skip to content

fix: keep loro-crdt sourcemap sources inside the package (#947)#987

Merged
zxch3n merged 1 commit into
mainfrom
fix/loro-issue-947
May 25, 2026
Merged

fix: keep loro-crdt sourcemap sources inside the package (#947)#987
zxch3n merged 1 commit into
mainfrom
fix/loro-issue-947

Conversation

@lodyai
Copy link
Copy Markdown
Contributor

@lodyai lodyai Bot commented May 25, 2026

Summary

  • Fixes #947: the published loro-crdt sourcemaps emit sources: ["../../index.ts"], which — resolved from node_modules/loro-crdt/<target>/index.js.map — escapes the package, so Vite/Vitest log: "Sourcemap for ... points to a source file outside its package: 'node_modules/index.ts'".
  • Root cause: @rollup/plugin-typescript hands rollup a map whose sources are relative to TS's intended JS output, but rollup resolves them against the .ts source directory, leaving an extra .. segment in the published map. Separately, sourcesContent was null because the plugin only auto-enables inlineSources when sourceMap is unset — but our tsconfig sets inlineSourceMap: true, which the plugin rewrites to sourceMap: true while leaving inlineSources off.
  • Fix in crates/loro-wasm/rollup.config.mjs:
    • Add output.sourcemapPathTransform that detects sources resolving outside the package and rewrites them to the real file inside the package (one less ..).
    • Set compilerOptions.inlineSources: true on the TS plugin so sourcesContent is populated.

After the fix, all four targets (nodejs, bundler, web, browser) emit sources: ["../index.ts"] with 12 788 chars of sourcesContent. Resolved from a published node_modules/loro-crdt/<target>/index.js.map, that lands on node_modules/loro-crdt/index.ts — inside the package — silencing the Vite warning.

Test plan

  • Rebuild rollup outputs and verify each */index.js.map's sources resolves inside the package
  • Verify sourcesContent is populated (no null)
  • After this PR's release, install loro-crdt in a Vite/Vitest project and confirm the warning is gone

🤖 Generated with Claude Code

Rewrite rollup output `sources` so they resolve inside the published
package and embed `sourcesContent`, removing the Vite/Vitest "source
file outside its package" warning users see for loro-crdt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

WASM Size Report

  • Original size: 2999.99 KB
  • Gzipped size: 990.47 KB
  • Brotli size: 695.95 KB

@zxch3n zxch3n merged commit f3ece99 into main May 25, 2026
1 check passed
@zxch3n zxch3n deleted the fix/loro-issue-947 branch May 25, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Published sourcemap's sources path escapes the package

1 participant